package com.rising.face.thread.pool;

import lombok.SneakyThrows;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * @Author: rising
 * @Description:
 * @Date: create in 2021/1/25 22:34
 */
public class ThreadPoolTest {
    private volatile  static  String aString = "awer";

    public static void main(String[] args) {
        ThreadPoolExecutor executorService = new ThreadPoolExecutor(2, 4, 5,
                TimeUnit.SECONDS,
                new ArrayBlockingQueue<>(4), new ThreadPoolExecutor.AbortPolicy());
        aString = "A";
        for (int i = 0; i < 10; i++) {
            executorService.execute(new Runnable() {
                @SneakyThrows
                @Override
                public void run() {
                    System.out.println("当前执行的线程是：" + Thread.currentThread().getName());
                    Thread.sleep(1000);
                }
            });
        }

    }

}
